
/* model */
import { ConnectorFormValue } from '@src/modules/connector/model/form/common'
/* types */
import {
  ConnectorFormValueProductType,
  ConnectorServerValueProductType
} from '@src/modules/connector/types'


class ConnectorFormValueProduct extends ConnectorFormValue {
  
  // 表单数据 -> 服务器数据
  formValueToServerValue(formValue: ConnectorFormValueProductType): ConnectorServerValueProductType {
    
    const id = formValue?.id || ''
    const name = formValue?.name || ''
    const customerId = formValue?.customerId || ''
    
    return {
      id,
      name,
      customerId
    }
    
  }
  
  // 服务器数据 -> 表单数据
  serverValueToFormValue(serverValue: ConnectorServerValueProductType): ConnectorFormValueProductType[] {
    
    const id = serverValue?.id || ''
    const name = serverValue?.name || ''
    const customerId = serverValue?.customerId || ''
    const customerName = ''
    const serialNumber = ''
    const type = ''
    
    return [{
      customerName,
      id,
      name,
      serialNumber,
      type,
      customerId
    }]
    
  }
  
}

export default ConnectorFormValueProduct